<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="renderer" content="webkit">
    <title>注册</title>
    <link href="static1/css/bootstrap.min-3.4.0.css" rel="stylesheet">
    <link href="static1/css/font-awesome-4.3.0.css" rel="stylesheet">
    <link href="static1/css/custom.css" rel="stylesheet">
    <link href="static1/css/animate.css" rel="stylesheet">
    <link href="static1/css/style-2.2.0.css" rel="stylesheet">
    <link href="static1/css/index.css" rel="stylesheet">
    <!-- 2. jQuery导入，建议使用1.9以上的版本 -->
    <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
    <script type="text/javascript"></script>
    <script>
		  // 核心业务逻辑
		  $(function(){
			  $("#submit").click(function(){
				  var username = $("#username").val();
				  var password = $("#password").val();

				  if(username.trim() == "" || password.trim() == "") {
					  alert("用户名或者密码不能为空！");
					  return;
				  }

				  $.ajax({
					  url:"/user/register",
					  data:{"username":username,"password":password},
					  type:"POST",
					  dataType:"json",
					  success:function(data) {
						  console.log(data);
						  if(data && data.userId > 0) {
							  alert("注册成功！");

							  window.location.href="login.html";
						  }else{
							alert("注册失败！");
							$("#user").val("");
							$("#password").val("");
						  }
					  }
				  });
			  });
		  });
	  </script>
</head>

<body class="gray-bg">
    <div class="middle-box text-center loginscreen animated fadeInDown">
                <div class="form-group">
                    <input id="username" type="text" class="form-control" placeholder="请自定义输入账号" >
                </div>
                <div class="form-group">
                    <input id="password"  type="password" class="form-control" placeholder="请输入密码" >
                </div>
                <button id="submit" class="btn btn-primary block full-width m-b">注 册</button>

                <p class="text-muted text-center"><small>已经有账户了？</small><a href="login.html">点此登录</a>
                </p>
                <img src="static1/picture/1.gif" style="width: 100%;">

        </div>
    </div>
</body>
</html>
